fix: fetch quota on manual refresh button click#449
Open
woai66 wants to merge 2 commits into
Open
Conversation
Previously, clicking the refresh button on an account card only refreshed the OAuth token without querying upstream quota data. Now, after a successful token refresh, we also call the Codex usage API to fetch and cache the current quota (7-day and 5-hour windows), so users can see usage data even without making proxy requests. Changes: - POST /auth/accounts/:id/refresh now fetches quota after token refresh - GET /auth/accounts?quota=fresh actively fetches quota for all accounts - Added tls.disable_websocket config option for proxies that don't support WebSocket - Proxy auto-detection now respects empty proxy_url config Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Use getConfig() when checking disable_websocket during implicit resume so the branch builds cleanly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner
|
Review notes: 这个 PR 目前我建议先不要合并,主要风险是它把一个现有代码刻意避开的路径重新加回来了。 现有 src/routes/accounts.ts 和 src/auth/health-check.ts 里已经有明确设计:RT exchange / health-check 只打 OAuth refresh endpoint,不要在刷新 RT 后马上请求 Codex /codex/usage,因为之前标注过这会触发 OpenAI risk detection / deactivation。 但这个 PR 在 POST /auth/accounts/:id/refresh 成功 probeAccount() 后马上 new CodexApi(...).getUsage(),等于手动 refresh 后立刻打 /codex/usage,风险比较高。 另外还有两个实现问题:
建议把 quota fresh 做成单独、受限、可选的路径,复用现有 quota refresher 的 concurrency / throttle 策略;不要挂在 token refresh 的同步路径后面。tls.disable_websocket 这部分也建议拆开或补完整设置入口和测试,尤其 implicit resume 依赖 WebSocket 支持 previous_response_id,禁用后的行为需要明确。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
quota=freshonGET /auth/accountsby actively refreshing quotas for active accountstls.disable_websocketconfig support and fix emptyproxy_urlhandling for environments where WebSocket/proxy behavior needs to be controlledProblem
After importing or adding accounts, the dashboard could show no quota usage until an account was actually used for a proxy request. Clicking the account refresh button only refreshed the OAuth token and checked health; it did not call the upstream Codex usage API. The top-level refresh button already requested
?quota=fresh, but the backend ignored that parameter.Solution
POST /auth/accounts/:id/refreshnow fetches upstream usage viaCodexApi.getUsage()after a successful token refresh and stores it viapool.updateCachedQuota().GET /auth/accounts?quota=freshnow refreshes quota for all active accounts before returning the account list.Test Plan
npm run build:webcd packages/electron && npm run build && npm run pack:win